package xiaohu.day7.HJ71;

import java.util.Scanner;


//通过率80%、在处理通配符时，会存在错误，如："*?*"与"abc"匹配，但实际结果为false
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String str1 = scanner.nextLine().toLowerCase();
            String str2 = scanner.nextLine().toLowerCase();
            int index = 0;
            int i = 0;
            for ( i = 0; i < str1.length() && index < str2.length(); i++) {
                //处理通配
                if (str1.charAt(i) == '?' || str1.charAt(i) == '*') {
                    if (str1.charAt(i) == '?') {
                        boolean isNumORABC = Character.isDigit(str2.charAt(index)) || Character.isAlphabetic(str2.charAt(index));
                        if (!isNumORABC) {
                            System.out.println("false");
                            return;
                        }
                        index++;
                    } else {
                        while (str1.charAt(i) == '*') {
                            i++;
                        }

                        while (str1.charAt(i) != str2.charAt(index)) {
                            boolean isNumORABC = Character.isDigit(str2.charAt(index)) || Character.isAlphabetic(str2.charAt(index));
                            if (!isNumORABC) {
                                System.out.println("false");
                                return;
                            }
                            index++;
                        }
                        while (index+1<str2.length() && str2.charAt(index) == str2.charAt(index + 1)) {
                            index++;
                        }
                        if (index == str2.length()) {
                            System.out.println("false");
                            return;
                        }else {
                            index++;
                        }

                    }
                } else {//处理常规情况
                    if (str1.charAt(i) == str2.charAt(index)) {
                        index++;
                    } else {
                        System.out.println("false");
                        return;
                    }

                }
            }
            if (i == str1.length() && index != str2.length()) {
                System.out.println("false");
                return;
            }
            System.out.println("true");
        }
    }
}
